function searchInsert(nums: number[], target: number): number {
    //二分查找法 0 1 2 3 4 5 6 7 8 
    let left = 0
    let right = nums.length - 1
    while(left <=right) {
      
      let mid = Math.floor((right - left)/2) + left
      console.log(left,right,mid)
      if(target <=nums[mid]) {
        right = mid - 1
      }else {
        left = mid + 1
      }
      console.log(left,right)
      console.log('--------')
    }
    return left
};

console.log(searchInsert([0,1,2,3,4,5,6,7,8],4))